////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Filename:    CaesarsEmpireGuts.cpp                                        //
//  Developer:   Tommy Riddle                                                 //
//  Create date: 02/15/2005                                                   //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Description: This is the class implementation for the slot gut of the     //
//               Australian Slot machine called Caesar's Empire.              //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//        Copyright (c) 2005 - Realtime Gaming.  All rights reserved.         //
////////////////////////////////////////////////////////////////////////////////

#include "CaesarsEmpireGuts.h"

////////////////////////////////////////////////////////////////////////////
/// CaesarsEmpireGuts::m_aLineWinSpinResults
///
/// This array is used to quickly get the SpinResult for the number of
/// icons.  It is indexed by wheel icon and then count.  So to get the
/// SpinResult for 5 Shields, use the following code snippet:
///
///		SpinResult result = m_aLineWinSpinResults[ ICON_SHIELD ][ 5 ];
///
/// In this example result would be set to EVT_FIVE_SHIELD.
////////////////////////////////////////////////////////////////////////////
CaesarsEmpireGuts::SpinResult CaesarsEmpireGuts::m_aLineWinSpinResults[][6] = 
{
// Number of icons:			0			1						2					3						4					5
/* ICON_NINE */			{	EVT_LOSER,	EVT_LOSER,		EVT_LOSER,			EVT_THREE_NINE,			EVT_FOUR_NINE,		EVT_FIVE_NINE		},
/* ICON_TEN */			{	EVT_LOSER,	EVT_LOSER,		EVT_LOSER,			EVT_THREE_TEN,			EVT_FOUR_TEN,		EVT_FIVE_TEN		},
/* ICON_JACK */			{	EVT_LOSER,	EVT_LOSER,		EVT_LOSER,			EVT_THREE_JACK,			EVT_FOUR_JACK,		EVT_FIVE_JACK		},
/* ICON_QUEEN */		{	EVT_LOSER,	EVT_LOSER,		EVT_LOSER,			EVT_THREE_QUEEN,		EVT_FOUR_QUEEN,		EVT_FIVE_QUEEN		},
/* ICON_KING */			{	EVT_LOSER,	EVT_LOSER,		EVT_LOSER,			EVT_THREE_KING,			EVT_FOUR_KING,		EVT_FIVE_KING		},
/* ICON_ACE */			{	EVT_LOSER,	EVT_LOSER,		EVT_LOSER,			EVT_THREE_ACE,			EVT_FOUR_ACE,		EVT_FIVE_ACE		},
/* ICON_FRUIT */		{	EVT_LOSER,	EVT_LOSER,		EVT_TWO_FRUIT,		EVT_THREE_FRUIT,		EVT_FOUR_FRUIT,		EVT_FIVE_FRUIT		},
/* ICON_SHIELD */		{	EVT_LOSER,	EVT_LOSER,		EVT_TWO_SHIELD,		EVT_THREE_SHIELD,		EVT_FOUR_SHIELD,	EVT_FIVE_SHIELD		},
/* ICON_HELMET */		{	EVT_LOSER,	EVT_LOSER,		EVT_TWO_HELMET,		EVT_THREE_HELMET,		EVT_FOUR_HELMET,	EVT_FIVE_HELMET		},
/* ICON_CLEOPATRA */	{	EVT_LOSER,	EVT_LOSER,		EVT_TWO_CLEOPATRA,	EVT_THREE_CLEOPATRA,	EVT_FOUR_CLEOPATRA,	EVT_FIVE_CLEOPATRA	},
/* ICON_COLISEUM */		{	EVT_LOSER,	EVT_LOSER,		EVT_LOSER,			EVT_LOSER,				EVT_LOSER,			EVT_LOSER			},
/* ICON_CAESAR */		{	EVT_LOSER,	EVT_ONE_CAESAR,	EVT_TWO_CAESAR,		EVT_THREE_CAESAR,		EVT_FOUR_CAESAR,	EVT_FIVE_CLEOPATRA	}  // Five Caesars are supposed to be converted to Five Cleopatras.
};

////////////////////////////////////////////////////////////////////////////
/// CaesarsEmpireGuts::m_aScatterWinSpinResults
///
/// This array is used to quickly get the SpinResult for the number of
/// icons.  It is indexed by icon count only, since Coliseums are the only
/// scatter win.  So to get the SpinResult for 5 Coliseums, use the
/// following code snippet:
///
///		SpinResult result = m_aScatterWinSpinResults[ 5 ];
///
/// In this example result would be set to EVT_FIVE_COLISEUM.
////////////////////////////////////////////////////////////////////////////
CaesarsEmpireGuts::SpinResult CaesarsEmpireGuts::m_aScatterWinSpinResults[6] = 
{
	// ICON_COLISEUM		   Number of Icons
	EVT_LOSER,				// 0
	EVT_SCATTER_NEAR_MISS,	// 1
	EVT_TWO_COLISEUM,		// 2
	EVT_THREE_COLISEUM,		// 3
	EVT_FOUR_COLISEUM,		// 4
	EVT_FIVE_COLISEUM		// 5
};

/* 09/10/2007, MVarela, 7.1.0, removed hard coded probability table 
(fix to allow 91% guts to work properly)*/

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::CaesarsEmpireGuts()   
///
/// This is the default constructor for the class.
////////////////////////////////////////////////////////////////////////////
CaesarsEmpireGuts::CaesarsEmpireGuts()
{
	// If this doesn't compile it means that someone probably added
	// another icon type but did not update the
	// m_aLineWinSpinResults array. 
	C_ASSERT( countof( m_aLineWinSpinResults ) == NUM_VALID_ICONS );

}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::~CaesarsEmpireGuts()
///
/// Destructor for CaesarsEmpireGuts. 
////////////////////////////////////////////////////////////////////////////
CaesarsEmpireGuts::~CaesarsEmpireGuts()
{
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::SpinResult CaesarsEmpireGuts::getCaesarLineWinResult( uint8* stops ) const
///
/// @param   stops			The array of stop positions for the line.
///
/// @return	 SpinResult		A payout from the SpinResult enumeration.
///
/// This helper method is used to calculate the Caesar line win payout.
////////////////////////////////////////////////////////////////////////////
CaesarsEmpireGuts::SpinResult CaesarsEmpireGuts::getCaesarLineWinResult( uint8* stops ) const
{
	// Count how many Caesars we have at the beginning of the line.
	for ( uint8 i = 0; i < getReelCount(); i++ )
    {
		// If this icon is not a Caesar...
		if ( getIcon( getGameModeId(), i, stops[i] )->iconid != ICON_CAESAR )
		{
			// then we have our total.
			break;
		}
    }

	// Use the array to look up the spin result for i Caesars.
	return lookupLineWinSpinResult( ICON_CAESAR, i );
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::SpinResult CaesarsEmpireGuts::getLineWinResultWithPossibleSubstitution( uint8* stops, uint8 testIcon, bool& bCaesarSubstitution ) const
///
/// @param   stops					The array of stop positions for the line.
/// @param   testIcon				The icon we are looking for, typically the first icon on the line.
/// @param   bCaesarSubstitution	An output parameter that is set if a subsitution is used.
///
/// @return	 SpinResult				A payout from the SpinResult enumeration.
///
/// This helper method is used to calculate the line win payout with a possible substitution.
////////////////////////////////////////////////////////////////////////////
CaesarsEmpireGuts::SpinResult CaesarsEmpireGuts::getLineWinResultWithPossibleSubstitution(
	uint8* stops, uint8 testIcon, bool& bCaesarSubstitution ) const
{
	// Initialize the out parameter
	bCaesarSubstitution = false;

	// Loop through the remaining reels until the streak is over
	for ( int i = 1; i < getReelCount(); i++ )
    {
		// See what this icon is.
		uint8 currentIcon = getIcon( getGameModeId(), i, stops[i] )->iconid;

		// If the current icon is a Caesar...
		if ( currentIcon == ICON_CAESAR )
		{
			// then use it as a substitution symbol and continue on.
			bCaesarSubstitution = true;
			continue;
		}
		// Otherwise if the test icon is a Caesar...
		else if ( testIcon == ICON_CAESAR )
		{
			// then we still have a Caesar substitution.  In this case the line
			// started out with a Caesar.
			bCaesarSubstitution = true;

			// We have now found our first icon that is not a Caesar.  All
			// of the rest of the icons will have to match this one now for the
			// streak to continue, so change our test icon.
			testIcon = currentIcon;
			continue;
		}

		// If the current icon is not the test icon...
        if ( currentIcon != testIcon )
        {
			// then the streak is over so break out of the loop
			break;
        }
    }

	// Use the array to look up the spin result for i testIcons.
	return lookupLineWinSpinResult( testIcon, i );
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 bool CaesarsEmpireGuts::doesCaesarLineWinPayMore( SpinResult srCaesar, SpinResult srOther, bool bCaesarSubstitution ) const
///
/// @param   srCaesar				The spin result to calculate the Caesar payout for.
/// @param   srOther				The spin result to calculate the other payout for.
/// @param   bCaesarSubstitution	Set if we should use the substitution multiplier with the other payout.
///
/// @return	 bool					True if the Caesar win is larger.
///
/// This helper method is used to see which payout is larger.
////////////////////////////////////////////////////////////////////////////
bool CaesarsEmpireGuts::doesCaesarLineWinPayMore( SpinResult srCaesar,
	SpinResult srOther, bool bCaesarSubstitution ) const
{
	// Lookup the payout for the Caesar line win.
	long nCaesarLineWinPayout = getPayout( srCaesar )->payoutAmount;

	// See what the total payout for the other line win is without the substitution
	// multiplier (if any).
	long nOtherLineWinPayout = getPayout( srOther )->payoutAmount;

	// If we had a substitution...
	if ( bCaesarSubstitution )
	{
		// then factor in the multiplier.
		nOtherLineWinPayout *= MULTIPLIER_CAESAR_SUBSTITUTION;
	}

	// Return true if the Caesar payout is bigger.
    return ( nCaesarLineWinPayout > nOtherLineWinPayout );
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::classifyStops()   
///
/// @param   stops      The array of stop positions for the line.
/// @param   bet        The value of the line bet.
/// @param   line       The index of the line.
///
/// @return	 uint8      A payout from the SpinResult enumeration as a uint8.    
///
/// This helper method is used to calculate the payout on a line.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::classifyStops( SpinLine* spinline, uint8* stops, uint8 bet, uint8 line,
	uint8& rtnresult, uint8& multiplier )
{
	// Track the Caesar result separately since it might be changed to a substitution.
	SpinResult srCaesarLineWinResult = getCaesarLineWinResult( stops );

	// Now see what the payout is if we use any Caesars we find as substitution symbols.
	// Start with the icon on the first reel.
	uint8 testIcon = getIcon( getGameModeId(), 0, stops[0] )->iconid;

	// If the Caesar result is five Cleopatras...
	if ( srCaesarLineWinResult == EVT_FIVE_CLEOPATRA )
	{
		// Special handling for 5 Caesars:  This will payout like 5 Cleopatra with a Caesar
		// substitution.  Just change the test icon to Cleopatra, then the code below will
		// correctly evaluate the line.
		testIcon = ICON_CLEOPATRA;
	}

	// Declare a local variable to track whether or not we found a Caesar substitution.
	bool bCaesarSubstitution = false;

	// See what the spin result is if we used any Caesars as substitution symbols.
	SpinResult srResultWithPossibleSubstitution =
		getLineWinResultWithPossibleSubstitution( stops, testIcon, bCaesarSubstitution );

	// Use the larger payout between the regular Caesar evaluation compared to
	// the evaluation with the possible Caesar substitution.
    if ( doesCaesarLineWinPayMore( srCaesarLineWinResult,
		srResultWithPossibleSubstitution, bCaesarSubstitution ) )
	{
		// The Caesars by themselves pay out more so use the Caesar result.
		rtnresult = srCaesarLineWinResult;
	}
	else
	{
		// Otherwise the result with the substitution (if any) paid more so use it.
		rtnresult = srResultWithPossibleSubstitution;

		// If we did actually have a substitution and a winning spin...
		if ( bCaesarSubstitution && srResultWithPossibleSubstitution != EVT_LOSER )
		{
			// then add a note and change the multiplier.
			spinline->addNote( NOTE_CAESAR_SUBSTITUTION );
			multiplier = MULTIPLIER_CAESAR_SUBSTITUTION;
		}
	}
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::ClassifyScattersHelper::ClassifyScattersHelper( CaesarsEmpireGuts* pOwner, SlotSpin* spin )
///
/// @param   pOwner     Pointer to the class that owns this helper object.
/// @param   spin       Pointer to the spin with stop data.
///
/// Constructor for the classify scatters helper class.
////////////////////////////////////////////////////////////////////////////
CaesarsEmpireGuts::ClassifyScattersHelper::ClassifyScattersHelper( CaesarsEmpireGuts* pOwner, SlotSpin* spin )
{
	// Save the owner so that we can call back to it as needed.
	m_pOwner = pOwner;

	// Save the spin so that we can add scatter results as needed.
	m_spin = spin;

	// Save the starting game mode in case we trigger the feature.
	m_gameMode = m_pOwner->getGameModeId();

	// If we are in the first paid spin (NOT a bonus spin)...
	if ( m_gameMode == MODE_NORMAL ) 
	{
		// then we don't have a multiplier, so set it to 1.
		m_multiplier = 1;
    }
	else
	{
		// Otherwise we are in free spin mode so use the free spin multiplier.
		m_multiplier = MULTIPLIER_FREE_SPIN;
	}

	// Keep up with the number of Coliseums we find so we can pay out for a scatter win.
	m_numColiseumIcons = 0;

	// Build a position mask of Coliseums in case we win the scatter.
	m_coliseumScatterPositions = 0;

    // Build a separate position mask of icons that help trigger the feature.
	m_featureTriggerPositions = 0;

	// Keep up with whether or not we find a Coliseum on the last reel so we can check
	// the feature trigger conditions later.
	m_bColiseumOnLastReel = false;

	// Keep up with whether or not we find a Caesar on any reel so we can check
	// the feature trigger conditions later.
	m_bFoundCaesar = false;
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::ClassifyScattersHelper::tryForJackpot()
///
///	This function tries to win the jackpot and adds the scatter if we hit
/// the jackpot.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::ClassifyScattersHelper::tryForJackpot()
{
	// If we are in the first paid spin (NOT a bonus spin)...
	if ( m_gameMode == MODE_NORMAL ) 
	{
		// then try for the Random Progressive Jackpot
		// If we hit the jackpot...
		if ( m_pOwner->getRandomProgressiveJackpotResult( m_spin->getSpinLineCount()) ||
			 m_pOwner->m_bForceRandomJackpot)
		{
			// then add a jackpot scatter to the spin.
			m_spin->addScatter( 0,
				m_pOwner->getPayout( EVT_RANDOM_PROGRESSIVE_WINNER )->payoutAmount, 1,
				true, EVT_RANDOM_PROGRESSIVE_WINNER, 0 );
		}
    }
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::ClassifyScattersHelper::awardExtraCaesarSpins( int32 thisCaesarPosition )
///
/// @param   thisCaesarPosition		The position bit mask for the Caesar.
///
/// This function is called to award extra free spins any time a Caesar
/// icon appears in the free game mode.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::ClassifyScattersHelper::awardExtraCaesarSpins(
	int32 thisCaesarPosition )
{
	// 09/10/2007, MVarela, 7.1.0, calculate the extra free spins by getting a
	// random number using a probability table from the database.
	int32 nFreeSpins = m_pOwner->getRandomValueFromProbabilityTable(PROBABILITY_TABLE_FREE_SPINS);	

	// Add the free spins.
	m_pOwner->incrementFreeSpins( nFreeSpins );

	// Add a scatter to the spin with the position of the Caesar that triggered these
	// free spins.
	m_spin->addScatter( thisCaesarPosition, 0, 0, false, EVT_FREE_GAMES, nFreeSpins );
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::ClassifyScattersHelper::evaluateScatterStop()
///
///	Evaluate the current stop to see if it has any relevant scatter icons
/// on it.  This function is called from a loop that iterates through each
/// stop in the wheel house.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::ClassifyScattersHelper::evaluateScatterStop()
{
	// Get the current stop.
	uint8 stop = m_pOwner->relativeWheelPosition( m_gameMode, m_reel,
		m_spin->getStops()[ m_reel ], m_row );

	// Get the icon for the current stop.
	uint8 currentIcon = m_pOwner->getIcon( m_gameMode, m_reel, stop )->iconid;
	
	// If the icon is a Coliseum...
	if ( currentIcon == ICON_COLISEUM )
	{
		// then increase the Coliseum count
		m_numColiseumIcons++;

		// Set the bit in the position mask for this stop.
        m_coliseumScatterPositions |= 1 << m_position;

		// If we are on the last reel...
		if ( m_reel == 4 )
		{
			// then remember that we found a Coliseum on the last reel.
			m_bColiseumOnLastReel = true;

			// Set the bit in the feature position mask for this stop.
			m_featureTriggerPositions |= 1 << m_position;
		}
    }
	// Otherwise if the icon is a Caesar...
	else if ( currentIcon == ICON_CAESAR )
	{
		// then remember that we found a Caesar
		m_bFoundCaesar = true;

		// Set the bit in a local position mask for this stop.
		int32 thisCaesarPosition = 1 << m_position;

		// If we are already in free spin mode
		if ( m_gameMode == MODE_FREE_SPIN )
		{
			// then award extra spins for each Caesar.
			awardExtraCaesarSpins( thisCaesarPosition );
		}
		else
		{
			// Otherwise save the position in the feature trigger mask
			// in case we trigger the feature on the last reel.
			m_featureTriggerPositions |= thisCaesarPosition;
		}
	}
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::ClassifyScattersHelper::lookForScatterIcons()
///
///	Loop through each stop in the wheel house and evaluate it for possible
/// scatter icons.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::ClassifyScattersHelper::lookForScatterIcons()
{
	// The position bit for the current icon in case it needs to be stored in a mask.
	m_position = 0;

	// Loop through each row in the wheel house.
	for( m_row = 0; m_row < 3; m_row++ )
	{
		// Loop through each reel.
  		for( m_reel = 0; m_reel < 5; m_reel++ )
		{
			// Look at the stop to see if it is a relevant scatter icon.
			evaluateScatterStop();

			// Move to the next bit in the position mask.
            m_position++;
		}
	}
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::ClassifyScattersHelper::evaluateScatterWin()
///
/// This function determines if the current spin wins a scatter payment and
/// adds the scatter.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::ClassifyScattersHelper::evaluateScatterWin()
{
	// See if we get the Coliseum scatter win.
	SpinResult srScatterResult = lookupScatterWinSpinResult( m_numColiseumIcons );

	// If we got the scatter win (or almost got it)
	if ( srScatterResult != EVT_LOSER )
	{
		// Get the base payout for the scatter.
		int32 nPayout = m_pOwner->getPayout( srScatterResult )->payoutAmount;
		
		// Scatters payout based on the total bet, so factor in the number of bet lines.
		nPayout *= m_spin->getSpinLineCount();

		// Add the payout (with multiplier) to the total win for this spin.
		m_pOwner->increaseTotalWin( nPayout * m_multiplier );
    
		// Add a scatter to the spin.
		SlotScatter* pScatter = m_spin->addScatter( m_coliseumScatterPositions,
			nPayout * m_pOwner->getBetPerLine(), m_multiplier, false, srScatterResult, 0 );

		// If the free spin multiplier was used...
		if ( m_multiplier == MULTIPLIER_FREE_SPIN )
		{
			// then add the free spin note.
			pScatter->addNote( NOTE_FREE_SPIN );
		}
	}
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::ClassifyScattersHelper::evaluateFeatureTrigger()
///
/// This function determines if the current spin triggered the free game
/// feature and adds the appropriate scatter.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::ClassifyScattersHelper::evaluateFeatureTrigger()
{
	// Check for the feature trigger if we started out in normal mode.
	if ( m_gameMode == MODE_NORMAL )
	{
		// If we found a Caesar...
		if ( m_bFoundCaesar )
		{
			// then we will at the very least have a near miss.
			SpinResult srFeatureTrigger = EVT_FEATURE_NEAR_MISS;

			// We need a place to keep up with how many free spins to award.
			int32 nFreeSpins = 0;

			// If there was a Coliseum on the last reel...
			if ( m_bColiseumOnLastReel )
			{
				// then we triggered the feature.
				m_pOwner->setGameModeId( MODE_FREE_SPIN );

				// The spin result is not a near miss any more.
				srFeatureTrigger = EVT_FREE_GAMES;

				// Award 10 free spins since it actually triggered.
				nFreeSpins = 10;

				// Add the free spins.
				m_pOwner->incrementFreeSpins( nFreeSpins );
			}

			// Add a scatter to the spin for the near miss or the feature trigger.
			m_spin->addScatter( m_featureTriggerPositions, 0, 0, false,
				srFeatureTrigger, nFreeSpins );
		}
	}
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::ClassifyScattersHelper::classifyScatters()
///
/// This function is called by the owner of the helper class to determine if
/// the current spin merits free spins or scatter payments.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::ClassifyScattersHelper::classifyScatters()
{	
	// Try for the Random Progressive Jackpot
	tryForJackpot();

	// Look at the wheel house and find the relevant scatter icons.
	lookForScatterIcons();

	// See if we get the Coliseum scatter win.
	evaluateScatterWin();

	// Now check for the feature trigger.
	evaluateFeatureTrigger();
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::classifyScatters( SlotSpin* spin )
///
/// @param   spin       Pointer to the spin with stop data.
///
/// This is an override of the framework method.  
/// It determines if the current spin merits free spins or scatter payments.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::classifyScatters( SlotSpin* spin )
{	
	// Use a helper class to figure everything out.
	ClassifyScattersHelper helper( this, spin );

	// Call the helper class to do all of the work.
	helper.classifyScatters();
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::isValidGuts()   
///
/// @return	 bool8      True if gut is valid.    
///
/// This helper method is used to see if the current gut ID is valid.
////////////////////////////////////////////////////////////////////////////
bool8 CaesarsEmpireGuts::isValidGuts()
{
	// Make sure that the m_aLineWinSpinResults array has an entry for each reel,
	// and an additional entry in case there are 0 icons on the line.
	// Note:  we can't do this in the constructor because we have to call
	// getReelCount.
	ASSERT( countof( m_aLineWinSpinResults[0] ) == getReelCount( MODE_NORMAL ) + 1 );

	// Make sure that the m_aScatterWinSpinResults array has an entry for each reel,
	// and an additional entry in case there are 0 icons on the line.
	ASSERT( countof( m_aScatterWinSpinResults ) == getReelCount( MODE_NORMAL ) + 1 );

	// Now make sure that both game modes have the same number of reels.
	ASSERT( getReelCount( MODE_NORMAL ) == getReelCount( MODE_FREE_SPIN ) );

	// Finally just check to see if the gut is within the right range.
    return ( getGutsId() >= 500 && getGutsId() < 600 );
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier, uint8& nNoteId )
///
/// @param   nGameModeMultiplier	The multiplier for the game mode.
/// @param   nNoteId				The note ID for the game mode.
///
/// This helper method is used to get the game mode multiplier and note ID.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier,
	uint8& nNoteId )
{
	// If we are in free spin mode...
    if ( getGameModeId() == MODE_FREE_SPIN )
    {
		// then return the free spin multiplier...
        nGameModeMultiplier = MULTIPLIER_FREE_SPIN;

		// and the free spin note.
        nNoteId = NOTE_FREE_SPIN;
    }
	// Otherwise...
    else
    {
		// just defer to the base class.
        SlotGuts::getGameModeMultiplierAndNoteId( nGameModeMultiplier, nNoteId );
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	Debugging code
//
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::preSpinClassifyResults( SlotSpin* spin )
///
/// @param   spin       Pointer to the spin with stop data.
///
/// This method is overridden in debug spins mode to alter the reel stops.
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::preSpinClassifyResults( SlotSpin* spin )
{
	SlotGuts::preSpinClassifyResults(spin);
	return;
}

////////////////////////////////////////////////////////////////////////////
/// @fn 	 CaesarsEmpireGuts::Debug_SetLoserStops( uint8* pStops )
///
/// @param   pStops		The stops to set.
///
/// Base class override, returns a losing spin triggered by the debug tool
////////////////////////////////////////////////////////////////////////////
void CaesarsEmpireGuts::Debug_SetLoserStops( uint8* pStops )
{
	pStops[0]=0;
	pStops[1]=3;
	pStops[2]=0;
	pStops[3]=0;
	pStops[4]=0;
}